package cn.woblog.recyclerviewsample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;

public class ListHeaderFooterActivity extends AppCompatActivity {

  private ListView lv;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_header_footer);

    lv = (ListView) findViewById(R.id.lv);

//    @NonNull Context context, @LayoutRes int resource,
//    @IdRes int textViewResourceId, @NonNull List<T> objects
//
    ArrayList<String> strings = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
      strings.add("item:" + i);
    }

    ArrayAdapter<String> data = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
        android.R.id.text1, strings);
    lv.setAdapter(data);

    lv.addHeaderView(getTextView());
  }

  private View getTextView() {
    View view = View.inflate(this, R.layout.header_1, null);
    return view;
  }
}
